home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
answrbok
/
6_6.lha
/
6_6
/
tst1.c
< prev
next >
Wrap
Text File
|
1993-08-08
|
1KB
|
53 lines
* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
* The C++ Answer Book */
* Tony Hansen */
* All rights reserved. */
include <6_6.h>
include <error.h>
ain()
string x[100];
cout << "here we go\n";
for (int n = 0; cin>>x[n]; n++)
{
string y;
if (n == 100) error("too many strings");
cout << (y = x[n]) << "\n";
if (y == "done") break;
}
cout << "here we go back again\n";
for (int i = n-1; 0 <= i; i--)
cout << x[i] << "\n";
string f = "0123456789"; // creates string "0123456789"
cout << "f = '" << f << "'\n";
cout << "f(3,3) = '" << f(3,3) << "'\n";
string g = f;
cout << "g = '" << g << "'\n";
g(3,3) = "abc"; // creates string "0123456789"
cout << "g(3,3)='abc' = '" << g << "'\n";
g = f;
cout << "g = '" << g << "'\n";
g(3,5) = "abc"; // creates string "0123456789"
cout << "g(3,5)='abc' = '" << g << "'\n";
g = f;
cout << "g = '" << g << "'\n";
g(3,1) = "abc"; // creates string "0123456789"
cout << "g(3,1)='abc' = '" << g << "'\n";
string f25 = f(2, 4); // creates string "2345"
cout << "f25 = '" << f25 << "'\n";
string f69 = f(6); // creates string "6789"
cout << "f69 = '" << f69 << "'\n";
string f57 = f(-5, 3); // creates string "567"
cout << "f57 = '" << f57 << "'\n";
return 0;